#ifndef _STRAWGUI_NAMED_OBJECT_H_
#define _STRAWGUI_NAMED_OBJECT_H_

#include "DataBase.h"
#include "sObserver.h"
#include "sGuiObject.h"

#ifdef _EDITOR
#include "sRTTIObject.h"
#endif

namespace sgui
{

namespace obs
{

	struct sChangeNameEvent : sEvent
	{
		std::wstring m_oldName;
		std::wstring m_newName;

		const EEventId getID() const { return EVID_CHANGE_NAME; }
		sChangeNameEvent(const std::wstring& oldname, const std::wstring& newname) : m_oldName(oldname), m_newName(newname) {}
	};

};
	
class sNamedObject: public obs::sSubject
	, public sGUIObject
#ifdef _EDITOR
	, public rtti::sObject
#endif
{
protected:
	std::wstring m_name;
public:
    const std::wstring& getName() const;
    void setName(const std::wstring& name);

    void save(db::Record& file) const;
    void load(const db::Record& file);

    void updateName(const std::wstring& name);

#ifdef _EDITOR
	void exportRTTI(rtti::sInfoList& list);
#endif

    sNamedObject(sGUI& gui, const std::wstring& name);
    ~sNamedObject();

};

};

#endif 